<template>
	<view class="news_wrap">
		<view class="news" v-for="item in news" :key="item.id" @click="handleNews(item.id)">
			<view class="img">
				<image :src="item.img_url" mode="widthFix"></image>
			</view>
			<view class="info">
				<view class="title">{{item.title}}</view>
				<view class="detail">
					<text>发表时间：{{item.add_time | formatDate}}</text>
					<text>浏览：{{item.click}}</text>
					<!-- <text>{{item.zhaiyao}}</text> -->
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				news:[]
			}
		},
		onLoad() {
			this.getNews()
		},
		methods: {
			async getNews(){
				const res = await this.$request({url:"/api/getnewslist"})
				this.news=res.data.message
			},
			handleNews(id){
				uni.navigateTo({
					url:`../newsDetail/newsDetail?id=${id}`
				})
			}
		}
	}
</script>

<style lang="scss">
.news_wrap{
	.news{
		border-bottom: 1px solid $color;
		max-height: 100px;
		padding: 5px;
		display: flex;
		.img{
			flex: 2;
			padding: 0 5px;
			image{
				width: 100%;
			}
		}
		.info{
			flex: 5;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			.title{
				font-size: 15px;
			}
			.detail{
				font-size: 12px;
				display: flex;
				justify-content: space-between;
			}
		}
	}
}
</style>
